﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LiteQueryWPF.Common
{
    class WinForm
    {
        public static Tuple<Nullable<bool>, Microsoft.Win32.OpenFileDialog> OpenFileDialog(
            string title = "打开文件",
            string filter = "Excel 97-2003(*.xls)|*.xls|Excel 2007(*.xlsx)|*.xlsx",
            bool mul = false)
        {
            var dlg = new Microsoft.Win32.OpenFileDialog()
            {
                Title = title,
                Multiselect = mul,
                Filter = filter
            };
            return new Tuple<Nullable<bool>, Microsoft.Win32.OpenFileDialog>(dlg.ShowDialog(), dlg);
        }

        public static Tuple<Nullable<bool>, Microsoft.Win32.SaveFileDialog> SaveFileDialog(
            string title = "保存文件",
            string defaultExt = ".xls",
            string filter = "Excel 97-2003(*.xls)|*.xls|Excel 2007(*.xlsx)|*.xlsx")
        {
            var dlg = new Microsoft.Win32.SaveFileDialog() {
                Filter = filter,
                FilterIndex = 0,
                Title = title,
                DefaultExt= defaultExt
            };
            
            return new Tuple<Nullable<bool>, Microsoft.Win32.SaveFileDialog>(dlg.ShowDialog(), dlg);
        }
    }
}
